package com.systop.asset.controller;

import java.util.List;
import com.systop.asset.entity.RestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.systop.asset.entity.MaterialRepository;
import com.systop.asset.service.IMaterialRepositoryService;

/**
 * 物料仓库Controller
 */
@RestController
@RequestMapping("/system/materialRepository")
public class MaterialRepositoryController {
    @Autowired
    private IMaterialRepositoryService materialRepositoryService;

    /**
     * 查询物料仓库列表
     */
    @GetMapping("/list")
    public RestResponse list(MaterialRepository materialRepository) {
        List<MaterialRepository> list = materialRepositoryService.selectMaterialRepositoryList(materialRepository);
        return RestResponse.success(list);
    }

    /**
     * 获取物料仓库详细信息
     */
    @GetMapping(value = "/{id}")
    public RestResponse getInfo(@PathVariable("id") Long id) {
        return RestResponse.success(materialRepositoryService.selectMaterialRepositoryById(id));
    }

    /**
     * 新增物料仓库
     */
    @PostMapping
    public RestResponse add(@RequestBody MaterialRepository materialRepository) {
        return RestResponse.success(materialRepositoryService.insertMaterialRepository(materialRepository));
    }

    /**
     * 修改物料仓库
     */
    @PutMapping
    public RestResponse edit(@RequestBody MaterialRepository materialRepository) {
        return RestResponse.success(materialRepositoryService.updateMaterialRepository(materialRepository));
    }

    /**
     * 删除物料仓库
     */
    @DeleteMapping("/{ids}")
    public RestResponse remove(@PathVariable Long[] ids) {
        return RestResponse.success(materialRepositoryService.deleteMaterialRepositoryByIds(ids));
    }
}